package com.service.bank.config;

import com.client.model.pojo.bank.ArElectronic;
import com.service.bank.service.ArElectronicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 周佳辉
 * @date 2024/4/10
 */
@Component
public class Myjob {

    @Autowired
    private ArElectronicService arElectronicService;

    //设置时间为24小时
//    @Scheduled(cron = "0 0 0 */24 * ?")
    //设置一小时执行一次
//    @Scheduled(cron = "0 0 * * * ?")
    //设置一分钟执行一次
//    @Scheduled(cron = "0 * * * * ?")
    //设置十分钟执行一次
    @Scheduled(cron = "0 0/10 * * * ?")
    public void job(){
        List<ArElectronic> arElectronicList = arElectronicService.list();

        for (ArElectronic arElectronic :arElectronicList){
            arElectronic.setDayDrawal(new BigDecimal(0));
            System.out.println("当前系统时间--"+ LocalDateTime.now());
        }

        arElectronicService.updateBatchById(arElectronicList);
    }

}


